﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;


namespace BillGuru.Persistence
{
    class SharedEventHandlerImpl
    {
        public static void RetrieveKeyOnRowInsert(object source, System.Data.OleDb.OleDbRowUpdatedEventArgs args)
        {
            if (args.StatementType == System.Data.StatementType.Insert)
            {
                OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY", args.Command.Connection);
                cmdNewID.Transaction = args.Command.Transaction;
                args.Row["ID"] = (int)cmdNewID.ExecuteScalar();
            }

        }
    }
}
